package ar.com.cema.methodology.analyzer.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
@Table(name="questions")
public class Question extends PersistentObject {
	@Column(nullable=false, unique=true)
	private String value;

	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable( name = "question_options", 
				joinColumns = { @JoinColumn(name = "question_id") }, 
				inverseJoinColumns = { @JoinColumn(name = "methodology_id") })
	private List<Methodology> options;
	
	
	@ManyToOne
	@JoinColumn(nullable=false, name="variable_id")
	private Variable variable;


	private String hint;

	
	public Question() {
		super();
		this.options = new ArrayList<Methodology>();
	}

	public Question(Long id) {
		super(id);
	}

	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public Variable getVariable() {
		return variable;
	}
	public void setVariable(Variable variable) {
		this.variable = variable;
	}

	public List<Methodology> getOptions() {
		return options;
	}

	public void setOptions(List<Methodology> options) {
		this.options = options;
	}

	public String getHint() {
		return hint;
	}

	public void setHint(String hint) {
		this.hint = hint;
	}
}